package cn.com.sd.system.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Proxy;

import cn.com.sd.log.model.ServiceLog;

@Entity
@Table(name="operator")
@Proxy(lazy = false)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Operator implements java.io.Serializable {

	private static final long serialVersionUID = 7228155662209882506L;
	
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Integer id;
	
	@Column(name = "name")
	private String name;
	
	@Column(name = "password")
	private String password;
	
	/*操作员类型*/
	@Column(name = "type")
	private String type; 
	
	/*证件类型*/
	@Column(name = "id_type")
	private String idType; 
	
	/*证件号码*/
	@Column(name = "id_nbr")
	private String idNbr; 
	
	/*电话号码*/
	@Column(name = "phone")
	private String phone; 
	
	/*地址*/
	@Column(name = "address")
	private String address;
	
	/*邮编*/
	@Column(name = "post_code")
	private String postCode; 
	
	/*邮箱*/
	@Column(name = "email")
	private String email;
	
	/*证书序列号*/
	@Column(name = "cert_sn")
	private String certSn; 
	
	/*证书主题*/
	@Column(name = "cert_dn")
	private String certDn; 
	
	/*证书实体*/
	@Column(name = "cert_entity")
	private String certEntity; 
	
	@Column(name = "status")
	private Integer status;
	
	@Column(name = "city")
	private String city;
	
	@Column(name = "province")
	private String province;
	
	/*用户创建时间*/
	@Column(name = "create_time")
	private String createTime;
	
	/*证件生效时间*/
	@Column(name = "valid_time")
	private String validTime;
	
	/*证件失效时间*/
	@Column(name = "expire_time")
	private String expireTime;
	
	@Column(name = "remark")
	private String remark;
	
	@ManyToMany(targetEntity = Role.class, fetch = FetchType.LAZY)
	@JoinTable(name = "operator_role", joinColumns = @JoinColumn(name = "oper_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<Role> roles;
	
	@ManyToMany(targetEntity = Privilege.class, fetch = FetchType.LAZY)
	@JoinTable(name = "operator_privilege", joinColumns = @JoinColumn(name = "oper_id"), inverseJoinColumns = @JoinColumn(name = "priv_id"))
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<Privilege> privileges;
	
	@ManyToOne(fetch=FetchType.LAZY, targetEntity=Organization.class)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@JoinColumn(name="org_id")
	private Organization organization;
	
	@OneToMany(mappedBy="operator", targetEntity=ServiceLog.class, fetch=FetchType.LAZY)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<ServiceLog> serviceLogs;
	
	public Set<ServiceLog> getServiceLogs() {
		return serviceLogs;
	}
	public void setServiceLogs(Set<ServiceLog> serviceLogs) {
		this.serviceLogs = serviceLogs;
	}
	public Set<Privilege> getPrivileges() {
		return privileges;
	}
	public void setPrivileges(Set<Privilege> privileges) {
		this.privileges = privileges;
	}
	public Organization getOrganization() {
		return organization;
	}
	public void setOrganization(Organization organization) {
		this.organization = organization;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getIdType() {
		return idType;
	}
	public void setIdType(String idType) {
		this.idType = idType;
	}
	public String getIdNbr() {
		return idNbr;
	}
	public void setIdNbr(String idNbr) {
		this.idNbr = idNbr;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getPostCode() {
		return postCode;
	}
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getCertSn() {
		return certSn;
	}
	public void setCertSn(String certSn) {
		this.certSn = certSn;
	}
	public String getCertDn() {
		return certDn;
	}
	public void setCertDn(String certDn) {
		this.certDn = certDn;
	}
	public String getCertEntity() {
		return certEntity;
	}
	public void setCertEntity(String certEntity) {
		this.certEntity = certEntity;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getValidTime() {
		return validTime;
	}
	public void setValidTime(String validTime) {
		this.validTime = validTime;
	}
	public String getExpireTime() {
		return expireTime;
	}
	public void setExpireTime(String expireTime) {
		this.expireTime = expireTime;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
	
}
